import createPersistedState from 'vuex-persistedstate'

/**
 * Vuex持久化储存
 * 根据模块选择储存位置
 */

const localStoragePlugins = createPersistedState({
  storage: window.localStorage,
  reducer(store) {
    return {
      app: store.app
    }
  }
})

const sessionStoragePlugins = createPersistedState({
  storage: window.sessionStorage,
  reducer(store) {
    return {
      user: {
        token: store.user.token,
        userinfo: store.user.userinfo
      }
    }
  }
})

export default [localStoragePlugins, sessionStoragePlugins]
